<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>钻石转移</title>
  <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
  <script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/mui.min.js"></script>
  <script>
    var width = window.localStorage.getItem('width');
    document.documentElement.style.fontSize = width ? width / 6.4 + 'px' : '55px';
  </script>
  <script src="../config.js"></script>
  <style>
    body,html{
      width: 100%;
      height: 100%;
      margin: 0;
      padding: 0;
      touch-action: none;
      overflow-x: hidden;
      overflow-y: auto;
      font-size: 0.28rem;
      background-color: #F2F2F2;
    }
    #app{
      width: 100%;
      padding-top: 5%;
    }
    p{
      margin: 0;
    }
    .userInfoListWrap{
      width: 90%;
      margin-left: 2%;
      margin-bottom: 0.5rem;
    }
    .userInfoTitle{
      font-size: 0.26rem;
      height: 0.5rem;
      line-height: 0.5rem;
      font-weight: bold;
    }
    .userInfoItem{
      font-size: 0.24rem;
      margin-left: 0.5rem;
      height: 0.4rem;
      line-height: 0.4rem;
    }
    .actionChooseBtnsWrap{
      display: flex;
      align-items: center;
      justify-content: space-between;
      width: 80%;
      margin: 1rem auto 0;
      height: 1rem;
    }
    .actionBtn{
      width: 40%;
      height: 0.8rem;
      text-align: center;
      font-size: 0.3rem;
      line-height: 0.8rem;
      border-radius: 0.1rem;
      color: white;
    }
    .confirmTransferBtn{
      background: rgb(255,152,0);
    }
    .cancleBtn{
      background: #9c9c9c;
    }





  </style>
</head>
<body>
<div id="app">
  <div class="userInfoListWrap">
    <div class="userInfoTitle">转移钻石会员：</div>
    <div class="userInfoItem">会员ID：{{oldUserInfo.userId}}</div>
    <div class="userInfoItem">会员昵称：{{oldUserInfo.userNick}}</div>
    <div class="userInfoItem">会员蓝钻数量：{{oldUserInfo.bindDiamond}}</div>
    <div class="userInfoItem">会员黄钻数量：{{oldUserInfo.diamond}}</div>
  </div>
  <div class="userInfoListWrap">
    <div class="userInfoTitle">接收钻石会员：</div>
    <div class="userInfoItem">会员ID：{{newUserInfo.userId}}</div>
    <div class="userInfoItem">会员昵称：{{newUserInfo.userNick}}</div>
    <div class="userInfoItem">会员蓝钻数量：{{newUserInfo.bindDiamond}}</div>
    <div class="userInfoItem">会员黄钻数量：{{newUserInfo.diamond}}</div>
  </div>
  <div class="actionChooseBtnsWrap">
    <div class="actionBtn confirmTransferBtn" @click="loadTransferResult">确定转移</div>
    <div class="actionBtn cancleBtn" @click="toBack">返回</div>
  </div>
</div>
<script src="../js/mui.min.js"></script>
<script type="text/javascript">
  var vm=new Vue({
    el:'#app',
    data:function () {
      return {
        oldUserId:'',//转移钻石用户id
        newUserId:'',//接收钻石用户id
        oldUserInfo:{
          userId:'',
          userNick:'',
          bindDiamond:'',
          diamond:'',
        },//转移钻石用户信息
        newUserInfo:{
          userId:'',
          userNick:'',
          bindDiamond:'',
          diamond:'',
        },//接收钻石用户信息
      }
    },
    created:function () {
      var vm = this
      mui.init();
      mui.plusReady(function() {
        vm.receiveParams();
      })
    },
    mounted:function () {

    },
    methods:{
      receiveParams: function() {
        var self = plus.webview.currentWebview();
        var vm=this;
        vm.oldUserId = self.oldUser;
        vm.newUserId = self.newUser;
        vm.loadTransferData();
      },
      loadTransferData:function () {
        var vm=this;
        console.log(vm.oldUserId);
        console.log(vm.newUserId);
        config.ajax({
          url:'/vipforward/getTransferDiamondData',
          data:{
            oldUserId:vm.oldUserId,//转移钻石用户id
            newUserId:vm.newUserId,//接收钻石用户id
          },
          success:function(res){
            console.log(JSON.stringify(res))
            if(res.result===1){
              vm.oldUserInfo=res.oldUser;
              vm.newUserInfo=res.newUser;
            }else{
              mui.toast(res.errormsg)
            }

          },
          error:function(res){
            mui.toast(res.errormsg)
          }
        });
      },
      toBack:function(){
        plus.webview.currentWebview().hide();
        plus.webview.currentWebview().close();
      },
      loadTransferResult:function () {
        var vm=this;
        config.ajax({
          url:'/vipforward/transferDiamond',
          data:{
            oldUserId:vm.oldUserId,//转移钻石用户id
            newUserId:vm.newUserId,//接收钻石用户id
          },
          success:function(res){
            console.log(JSON.stringify(res))
            if(res.result===1){
              vm.toDiamondTransferResult(res.oldUser,res.newUser);
            }else{
              mui.toast(res.errormsg);
            }
          },
          error:function(res){
            mui.toast(res.errormsg);
          }
        });
      },
      toDiamondTransferResult:function(oldInfo,newInfo){
        var vm=this;
        mui.openWindow({
          url: 'diamondTransferResult.html',
          id: 'diamondTransferResult',
          styles: {
            titleNView: {
              titleText:'钻石转移',
              titleColor: "#FFFFFF",
              titleSize: "14px",
              backgroundColor: "#FF6800",
              autoBackButton: true,
              splitLine: {
                color: "#CCCCCC",
                height: "1px"
              }
            }
          },
          extras: {
            oldUserInfo:oldInfo,
            newUserInfo:newInfo,
          }
        });
      }

    },


  })
</script>
</body>
</html>